import json

dictA={
    "status": 1,
    "code": 10000,
    "message": "访问成功"
}
# ensure_ascii=true 默认是中文转换成ascii码
# json1=json.dumps(dictA,ensure_ascii=False)
# print(type(json1))
#,encoding="utf8"
with open(r"..\b.json","w")  as file:
    # json.dumps(dictA) 只是返回一个字符串类型的json,并不能写入文件
    # file.write( json.dumps(dictA))#只能通过file.write()来写入
    #json.dump()把字典直接写入到json文件中
    json.dump(dictA,file,ensure_ascii=False)


